package com.letou.ls.ui;

import com.letou.ls.R;
import com.letou.ls.uitl.Constant;
import com.letou.ls.uitl.DialogUtils;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Bundle;
import android.widget.TextView;

public class AboutActivity extends Activity {
    
    private TextView mUsername;
    private TextView mVersion;
    private TextView about_weixin;
    private TextView mCompany;
    private TextView mTell;
    private TextView mQQ;
    private TextView mWebsite;
    // private FinalHttp fh = null;
    private ProgressDialog mProgressDialog;
    private int currentOrientation;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        currentOrientation =
                getIntent().getIntExtra("orientation", Configuration.ORIENTATION_LANDSCAPE);
        if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            setContentView(R.layout.activity_about_landscape);
        } else {
            setContentView(R.layout.activity_about_portrait);
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
        
        
        mUsername = (TextView) findViewById(R.id.about_user_name);
        mVersion = (TextView) findViewById(R.id.about_version);
        about_weixin = (TextView) findViewById(R.id.about_weixin);
        mCompany = (TextView) findViewById(R.id.about_company);
        mTell = (TextView) findViewById(R.id.about_tell);
        mQQ = (TextView) findViewById(R.id.about_qq);
        mWebsite = (TextView) findViewById(R.id.about_website);

        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setMessage("数据加载中请稍候...");
    }

    @Override
    protected void onStart() {
        // TODO Auto-generated method stub
        super.onStart();
        updateView();
    }

    private void updateView() {
        
        // "qq":"2023424537","website":"http:\/\/xxx.xxx.xx","code":200,"company":"轶想科技(北京)有限公司","tel":"010-56148462","message":"","expirationDate":"2016-12-27"}
        mUsername.setText(Constant.userName);
        mVersion.setText("v" + Constant.getCurrentVersion(this));
        about_weixin.setText("yxletou");
        mCompany.setText("轶想科技(北京)有限公司");
        mTell.setText("010-56148462");
        mQQ.setText("2023424537");
        mWebsite.setText("http://www.le-tou.com.cn");
    }



    // public void loadData() {
    //
    // mProgressDialog.show();
    // // 网络连接类
    // fh = new FinalHttp();
    // //
    // http://119.10.9.19:8080/lottery/api/lottery/getAbout?typeCode=hljklsfmj&token=1FF114B7BB0478F3B61A5EDAE3B6AF0B
    //// "qq":"2023424537","website":"http:\/\/xxx.xxx.xx","code":200,"company":"轶想科技(北京)有限公司","tel":"010-56148462","message":"","expirationDate":"2016-12-27"}
    //
    // String url = Constant.URL_SERVER_ABOUT + "?typeCode=" +
    // Constant.getCurrentLotteryCode() + "&token="
    // + Constant.token;
    // Logger.v("lss", url);
    // // 获取IMEI
    // fh.configTimeout(30000);
    // fh.get(url, new AjaxCallBack<String>() {
    // @Override
    // public void onSuccess(String strJson) {
    //
    // Logger.v("lss", "strJson " + strJson);
    // // 登陆结果转换
    // AboutInfo aboutInfo = JsonUtil.fromJson(strJson, AboutInfo.class);
    //
    // // 登陆成功
    // if ("200".equals(aboutInfo.getCode())) {
    //
    // if (mProgressDialog.isShowing()) {
    // mProgressDialog.dismiss();
    // }
    // updateView(aboutInfo);
    // // 登陆失败
    // } else {
    // failureProcess(aboutInfo.getMessage());
    // }
    // }
    //
    // @Override
    // public void onFailure(Throwable t, int errorNo, String strMsg) {
    // // TODO
    // failureProcess("网络超时");
    // }
    //
    // // 失败操作
    // private void failureProcess(String msg) {
    // // 跳转至登陆页面
    // //
    // showDailog(msg);
    // }
    //
    // });
    // }

    private void showDailog(String message) {
        if (mProgressDialog.isShowing()) {
            mProgressDialog.dismiss();
        }
        DialogUtils.showDialog(this, "提示", message);
    }
}
